package com.atguigu.jxc.controller;

import com.atguigu.jxc.entity.GoodsTree;
import com.atguigu.jxc.service.GoodsService;
import com.google.gson.Gson;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zhmwi
 * @Date 2021/9/4
 * @Dersciption 商品管理
 */
@RestController
@RequestMapping("goodsType")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    /**
     * 查询分级子树
     * @return
     */
    @PostMapping("loadGoodsType")
    public String loadGoodsType(){
        List<GoodsTree> goodsTreeList = goodsService.loadGoodsType();
        return new Gson().toJson(goodsTreeList.get(0));
    }
}
